<template>
  <div>
    主题名称：<input type="text" v-model="paramsObj.title">
    作者：<input type="text" v-model="paramsObj.username">
    起始日期：<input type="text" v-model="paramsObj.startDate">
    结束日期：<input type="text" v-model="paramsObj.endDate">
    <input type="button" value="搜索" @click="findByItem(1)">
   <router-link :to="{name:'AddPost',query:{channelId:paramsObj.channelId}}">发表主题</router-link>

    <table border="1" width="100%" cellspacing="1">
      <thead>
      <tr>
        <th>主题</th>
        <th>作者</th>
        <th>回帖数量</th>
        <th>发帖时间</th>
      </tr>
      </thead>
      <tbody>
      <tr v-for="p in postIPage.records" :key="p.id">
        <td><router-link :to="{name:'Replay',query:{postId:p.id}}">{{ p.title }}</router-link></td>
        <td>{{ p.user.username }}</td>
        <td>{{ p.replayNum }}</td>
        <td>{{ p.time }}</td>
      </tr>
      </tbody>
    </table>
    <div>
      <a v-for="p in postIPage.pages" :key="p" href="javascript:void (0)" @click="findByItem(p)"
         style="margin-left: 10px">{{ p }}</a>
    </div>
  </div>
</template>

<script>
import axios from 'axios'

export default {
  data() {
    return {
      postIPage: {},
      paramsObj: {}
    }
  }, created() {
    this.findByItem(1);
  }, methods: {
    findByItem(pageNO) {
      this.paramsObj.pageNO = pageNO;
      this.paramsObj.channelId = this.$route.query.channelId;
      axios.get("/project/post/findByItem", {
        params: this.paramsObj
      }).then(resp => {
        this.postIPage = resp.data;
      })
    }
  }
}
</script>

<style scoped>

</style>